import React from 'react'
import { store } from '../stores'
import { useEffect, useState } from 'react'
import { detail } from '../type/home'

function useBadge () {
  const [cartsList, setCartList] = useState<detail[]>([])
  useEffect(() => {
    // console.log(store.getState().cart)
    setCartList(store.getState().CartStore) // console.log(store.getState().cart)
    const unsubscrible = store.subscribe(() => {
      setCartList(store.getState().CartStore)
    })
    return () => {
      unsubscrible()
    }
  }, [])
}
export { useBadge }
